package com.study.d020language;

import java.net.URL;
import java.util.Locale;
import java.util.ResourceBundle;

import javafx.application.Application;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;

/**
 * 国际化的使用
 *
 * @description
 * @author xtayhame date 2020年3月17日 version since v1.0
 */
public class LanguageMain extends Application {
	public static void main(String[] args) {
		launch(args);
	}

	@Override
	public void start(Stage stage) throws Exception {
		Locale locale = Locale.getDefault();
		System.out.println("获取本地语言：" + locale.getLanguage());
		System.out.println("获取所属国家：" + locale.getCountry());

		System.out.println("重新设置语言：");
		// 默认是本地的语言
		// 这里设置为台湾
		Locale.setDefault(new Locale("zh", "TW"));

		locale = Locale.getDefault();
		System.out.println("获取本地语言：" + locale.getLanguage());
		System.out.println("获取所属国家：" + locale.getCountry());

		// 获取语言
		ResourceBundle rb = ResourceBundle.getBundle("com/study/d020language/language");

		URL url = FXMLLoader.getDefaultClassLoader().getResource("com\\study\\d020language\\language.fxml");
		AnchorPane anchorPane = (AnchorPane) FXMLLoader.load(url, rb);

		stage.setScene(new Scene(anchorPane, 400, 300));
		stage.show();
	}
}
